<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>大事件-后台登录页</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <!-- 引入bootstrap的css文件 -->
    <link rel="stylesheet" href="./libs/bootstrap/css/bootstrap.min.css" />
    <!-- 引入jq文件 -->
    <script src="./libs/jquery-1.12.4.min.js"></script>
    <!-- 引入bootstrap的js文件 -->
    <script src="./libs/bootstrap/js/bootstrap.min.js"></script>

</head>

<body>
    <div class="main_wrap">
        <div class="header">
            <a href="#" class="logo"><img src="images/logo.png" alt="" /></a>
            <div class="copyright">
                CopyRight © 2019 深圳百秀信息技术股份有限公司<br />All Rights Reserved
            </div>
        </div>

        <div class="login_form_con">
            <div class="login_title"></div>
            <form class="login_form">
                <i class="iconfont icon-user"></i>
                <i class="iconfont icon-key"></i>
                <input type="text" class="input_txt" placeholder="邮箱/手机号" />
                <input type="password" class="input_pass" placeholder="密码" />
                <input type="submit" class="input_sub" value="登 录" />
            </form>
        </div>
    </div>

    <!-- 准备模态框静态结构 -->
    <div id="myModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">温馨提示</h4>
                </div>
                <div class="modal-body">
                    <p>One fine body&hellip;</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">确定</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->


</body>

</html>
<script src="./libs/https.js"></script>
<script>
    $(function() {
        //给登录按钮设置点击事件
        $('.input_sub').on('click', function(e) {
            //在form里的按钮要清除默认刷新功能
            e.preventDefault()
                //获取客户输入的数据信息
            let username = $('.input_txt').val().trim()
            let password = $('.input_pass').val().trim()
                //判断客户是否有输入内容
            if (username == '' || password == '') {
                //用模态框实现弹窗功能
                //首先要给模态框添加一个id名
                //提醒文本不能写死，替换p标签里的文本
                $('.modal-body p').text('傻猪猪,不能为空!');
                $('#myModal').modal();
                //返回值
                return
            }

            $.ajax({
                type: 'post',
                url: BigNew.user_login,
                data: {
                    username: username,
                    password: password,
                },
                success: function(jieguo) {
                    //获取token并保存起来
                    localStorage.setItem('token79', jieguo.token)
                        //获取数据，p标签里的文本用返回的数据替换
                    $('.modal-body p').text(jieguo.msg)
                    $('#myModal').modal()
                        //给模态框固定的点击事件 hidden.bs.modal
                    $('#myModal').on('hidden.bs.modal', function() {
                        //判断是否有获取到数据
                        if (jieguo.code == 200) {
                            //有获取到数据并点击确定，就跳转到该页
                            window.location = './index.html'
                        } else {
                            //清空输入框的所有输入的内容
                            $('.input_txt').val('')
                            $('.input_pass').val('')
                        }
                    })

                }
            })


        })

    })
</script>